package com.huarui.desktop.model;

import org.apache.commons.lang.StringUtils;

public class ModuleScriptFunct {
	private String name;
	private String[] params;
	private StringBuilder content;

	public ModuleScriptFunct(String name) {
		this.name = name;
		this.content = new StringBuilder();
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String[] getParams() {
		return params;
	}

	public void setParams(String[] params) {
		this.params = params;
	}

	public StringBuilder getContent() {
		return content;
	}

	public void addContentLine(CharSequence content) {
		this.content.append(content).append('\n');
	}

	public void setContent(StringBuilder content) {
		this.content = content;
	}

	public String getParameter(){
		if (params != null) {
			return StringUtils.join(params, ',');
		}
		return "";
	}
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append(this.name + " : function (");
		if (params != null) {
			builder.append(StringUtils.join(params, ','));
		}
		builder.append(") {\n");
		builder.append(this.content);
		builder.append("}");
		return builder.toString();
	}
}